import de.pixel83.piecemaster.Board;
import de.pixel83.piecemaster.Board.MoveResult;
import de.pixel83.piecemaster.Move;
import de.pixel83.piecemaster.ai.*;

public class AiCompare {
	public static void main(String[] args) {
		System.out.println("testing moves");

		int countWinai0 = 0;
		int countWinai1 = 0;
		int countIllegal = 0;
		int countDraw = 0;
		Board board;
		Ai[] ais = new Ai[2];
		System.out.println("made an ai");

		while (countWinai0 + countWinai1 + countDraw < 1) {
			board = new Board();
			// WinW = 1
			// WinB= 0
			// ais[0] = new RandomAi();
			// ais[0] = new MasterAi();
			ais[0] = new MasterAi3();
			// ais[1] = new MasterAiMichi(new
			// DNA("bishop=425;pawn-increase=50;queen=1020;king=12563;rook=642;pawn=158;knight=202"));
			// // hier zu vergleichende ais
			// ais[0] = new MasterAiMichi();
			// ais[0] = new MasterAiMichi(p, n, b, r, q, k, pinc);
			ais[1] = new MasterAiMichi();

			int i = 0;
			char color = 'B';

			Board.MoveResult result = Board.MoveResult.OK;
			// System.out.println("made a move");

			do {
				if (i == 1) {
					i--;
					color = Board.invertColor(color);
				} else {
					i++;
					color = Board.invertColor(color);
				}

				System.out.println("ai " + ais[i].toString() + " am zug ("
						+ color + ")");
				long time = System.currentTimeMillis();
				Move mov = ais[i].draw(board, color);
				System.out.println((System.currentTimeMillis() - time));
				System.out.println(mov.toString());
				result = board.move(mov);

				System.out.println("made a move");
				System.out.println(board.toString());
			} while (result == Board.MoveResult.OK);

			// System.out.println(board.toString());
			System.out.println(result.toString());
			switch (result) {
			case WIN_W:
				countWinai1++;
				break;
			case WIN_B:
				countWinai0++;
				break;
			case ILLEGAL:
				countIllegal++;
				break;
			case DRAW:
				countDraw++;
				break;

			}
		}
		// if (countDraw > 0) {
		System.out.println("Win W : " + countWinai1);
		System.out.println("Win B : " + countWinai0);
		System.out.println("Draws: " + countDraw);
		System.out.println("Illegal: " + countIllegal);
		// System.out.println("p" + p + "n" + n + "b" + b + "r" + r + "q" + q
		// + "k" + k);
		// System.out.println(p);
		// System.out.println(n);
		// System.out.println(b);
		// System.out.println(r);
		// System.out.println(q);
		// System.out.println(k);

		// }
		// }
	}
}
